﻿using Microsoft.Maps.MapControl.WPF;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TrailMapManager.Common.Track
{
    public class TrailTrackPoint
    {
        public DateTime TimeStamp { get; set; }
        public Location Position { get; set; }
        public double Altitude { get; set; }
        public double Speed { get; set; }

        public TrailTrackPoint()
        {

        }

        public TrailTrackPoint(byte[] data, int index)
        {
            TimeStamp = new DateTime(BitConverter.ToInt64(data, index)); //8 byte
            Position = new Location(BitConverter.ToSingle(data, index + 12), BitConverter.ToSingle(data, index + 8)); //16 byte
            Altitude = BitConverter.ToDouble(data, index + 16); // 24byte
            Speed = BitConverter.ToDouble(data, index + 24); // 32byte
        }

        //public byte[] GetBytes()
        //{
        //    byte[] data = new byte[32];

        //    Buffer.BlockCopy(BitConverter.GetBytes(TimeStamp.Ticks), 0, data, 0, 8);
        //    Buffer.BlockCopy(BitConverter.GetBytes(Position.Longitude), 0, data, 8, 4);
        //    Buffer.BlockCopy(BitConverter.GetBytes(Position.Latitude), 0, data, 12, 4);
        //    Buffer.BlockCopy(BitConverter.GetBytes(Altitude), 0, data, 16, 8);
        //    Buffer.BlockCopy(BitConverter.GetBytes(Speed), 0, data, 24, 8);

        //    return data;
        //}
    }
}
